//
//  ICNavigationController.m
//  ICome
//
//  Created by ENN on 16/2/17.
//  Copyright © 2016年 XianZhuangGuo. All rights reserved.
//

#import "ICNavigationController.h"
#import "ICHeaderFile.h"

@interface ICNavigationController ()

@end

@implementation ICNavigationController

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
    self = [super initWithRootViewController:rootViewController];
    if(self)
    {
        [self setNavBarButtonItem];
        [self setNavBarItem];
    }
    return self;
}

//+ (void)initialize
//{
//    // 设置item主题样式
//    [self setNavBarButtonItem];
//
//    [self setNavBarItem];
//}

- (void)setNavBarButtonItem
{
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = DEFAULT_SUBJECT_COLOR;//DEFAULT_SUBJECT_COLOR
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:15.0];
    [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [item setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];
}

- (void)setNavBarItem
{
    UINavigationBar * navBar = [UINavigationBar appearance];
    // title 文字 字号 颜色 ICBOLDFont(18)
    [navBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica-Bold" size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    // 默认背景给替换
    [navBar setBackgroundImage:[UIImage imageWithColor:NE_BACKGROUND_COLOR size:CGSizeMake(App_Frame_Width, 1)] forBarMetrics:UIBarMetricsDefault];
    //渲染导航栏按钮颜色
    navBar.tintColor = [UIColor whiteColor];
    // 设置nav下方黑线 导航底部线   NE_LINE_COLOR
    [navBar setShadowImage:[UIImage imageWithColor:NE_BACKGROUND_COLOR size:CGSizeMake(App_Frame_Width, 0.5)]];
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

// 重写该方法，判断是否隐藏tabbar
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}


//- (UIStatusBarStyle)preferredStatusBarStyle
//{
//    return UIStatusBarStyleLightContent;
//}
//
//- (UIViewController *)childViewControllerForStatusBarStyle {
//    return self.topViewController;
//}


@end

